export * from './formdata'
export * from './image'
export { merge, isString } from "es-toolkit"

export function formatTime(timestamp: number | string) {
  if (!timestamp) {
    return timestamp
  }
  // 创建一个新的 Date 对象
  const date = new Date(Number(timestamp))
  // 获取年、月、日、时、分、秒
  const year = date.getFullYear()
  const month = String(date.getMonth() + 1).padStart(2, '0') // 月份从0开始，所以要加1
  const day = String(date.getDate()).padStart(2, '0')
  const hours = String(date.getHours()).padStart(2, '0')
  const minutes = String(date.getMinutes()).padStart(2, '0')
  const seconds = String(date.getSeconds()).padStart(2, '0')
  // 返回格式化后的字符串
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}

export function formatDate(timestamp: number | string) {
  if (!timestamp) {
    return timestamp
  }
  // 创建一个新的 Date 对象
  const date = new Date(Number(timestamp))
  // 获取年、月、日、时、分、秒
  const year = date.getFullYear()
  const month = String(date.getMonth() + 1).padStart(2, '0') // 月份从0开始，所以要加1
  const day = String(date.getDate()).padStart(2, '0')
  // 返回格式化后的字符串
  return `${year}-${month}-${day}`
}

export function checkPhone(phone: string) {
  const regex = /^1[3-9]\d{9}$/
  return regex.test(phone)
}

/**
 * 获取当前页面路径
 * @returns 当前页面路径
 */
export function getCurrentPath() {
  const pages = getCurrentPages()
  const currentPage = pages[pages.length - 1]
  return currentPage.route || ''
}